package com.erp.app.common.documentView.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.erp.framework.exceptions.FindRecordException;
import com.erp.framework.model.dao.SimplePageEditStyleDao;
import com.erp.framework.model.vo.ChildList;
import com.erp.framework.model.vo.SimpleBaseVo;

public abstract class DocumentViewDao extends SimplePageEditStyleDao {

    /**
     * To be implemented by subclass 
     */
    protected abstract String sqlFind();

    /**
     * To be implemented by subclass 
     */
    protected abstract void setValuesForFind(PreparedStatement pStmt, Object obj) throws SQLException;

    /**
     * To be implemented by subclass 
     */
    protected abstract String sqlList();        

    /**
     * To be implemented by subclass 
     */
    protected abstract void setValuesForList(PreparedStatement pStmt, Object obj) throws SQLException;

    /**
     * To be implemented by subclass 
     */
    protected abstract SimpleBaseVo getResultSetValues(ResultSet rs) throws SQLException;

    /**
     * To be implemented by subclass 
     */
    protected abstract Class getDocumentViewVoClass();    

    public ChildList selectByParent(SimpleBaseVo parent, Connection conn) throws FindRecordException {
        return super.selectByParent(parent, getDocumentViewVoClass(), conn);
    }

    //Since we are accessing a view, everything related to insert/update/delete is not needed
    protected String sqlInsert() {
        return null;
    }

    //Since we are accessing a view, everything related to insert/update/delete is not needed
    protected void setValuesForInsert(PreparedStatement pStmt, Object obj) throws SQLException {
    }

    //Since we are accessing a view, everything related to insert/update/delete is not needed
    protected String sqlUpdate() {
        return null;
    }

    //Since we are accessing a view, everything related to insert/update/delete is not needed
    protected void setValuesForModify(PreparedStatement pStmt, Object obj) throws SQLException {
    }

    //Since we are accessing a view, everything related to insert/update/delete is not needed
    protected String sqlDelete() {
        return null;
    }

    //Since we are accessing a view, everything related to insert/update/delete is not needed
    protected void setValuesForDelete(PreparedStatement pStmt, Object obj) throws SQLException {
    }

    protected boolean isViewOnly() {
        return true;
    }

}
